<script setup lang="ts">
const $emit = defineEmits(["foo", "click"]);
const handler = () => {
  $emit("foo", "东风快递", "使命必达");
};
</script>

<template>
  <div class="child">
    <p>我是子组件2</p>
    <button @click="handler">点我触发自定义foo事件</button>
    <button @click="$emit('click', '天堂水，龙井茶')">
      点我触发自定义click事件
    </button>
  </div>
</template>

<style scoped>
.child {
  width: 400px;
  height: 100px;
  background: brown;
  padding: 0.5rem;
  color: aliceblue;
}
</style>
